home *** CD-ROM | disk | FTP | other *** search
- head 1.3;
- access;
- symbols
- start:1.1.1.1 oleg:1.1.1;
- locks; strict;
- comment @// @;
-
-
- 1.3
- date 2005.01.09.20.13.54; author oleg; state Exp;
- branches;
- next 1.2;
-
- 1.2
- date 2005.01.09.19.22.43; author oleg; state Exp;
- branches;
- next 1.1;
-
- 1.1
- date 2005.01.09.18.45.06; author oleg; state Exp;
- branches
- 1.1.1.1;
- next ;
-
- 1.1.1.1
- date 2005.01.09.18.45.06; author oleg; state Exp;
- branches;
- next ;
-
-
- desc
- @@
-
-
- 1.3
- log
- @No log message.
- @
- text
- @#import "RocketLauncher.h"
- #import "AppInfo.h"
-
- @@implementation RocketLauncher
-
- -(void)setAllApps {
- NSArray *aa = [AppInfo allApps:allApps];
- [allApps release];
- allApps = [aa retain];
- }
-
- -(void)setApps {
- [resultTable deselectAll:nil];
- NSString *sv = [searchField stringValue];
- NSCharacterSet *ws = [NSCharacterSet whitespaceAndNewlineCharacterSet];
- NSCharacterSet *alNum = [NSCharacterSet alphanumericCharacterSet];
- NSCharacterSet *upper = [NSCharacterSet uppercaseLetterCharacterSet];
- sv = [sv stringByTrimmingCharactersInSet:ws];
- size_t len = [sv length];
- [apps removeAllObjects];
- if (len == 0) {
- [apps addObjectsFromArray:allApps];
- [resultTable reloadData];
- return;
- }
- int i;
- NSString *matchApp = [prefs appForString:sv];
- int matchIdx = 0;
- for (i = 0; i < [allApps count]; i++) {
- AppInfo *ai = [allApps objectAtIndex:i];
- NSString *name = [ai name];
- size_t nlen = [name length];
- NSRange scope = NSMakeRange(0, nlen);
- BOOL matches = NO;
- while (scope.length > 0) {
- NSRange r = [name rangeOfString:sv options:NSCaseInsensitiveSearch range: scope];
- if (r.location == NSNotFound) break;
- if (r.location == 0) { matches = YES; break; }
- unichar pc = [name characterAtIndex:r.location-1], c = [name characterAtIndex:r.location];
- if (![alNum characterIsMember:pc]) { matches = YES; break; }
- if ([upper characterIsMember:c] && ![upper characterIsMember:pc]) { matches = TRUE; break; }
- // Put word matching rules for your favourite language here
- scope.location = r.location+1;
- scope.length = nlen-scope.location;
- }
- if (matches) {
- if (matchApp != nil && [matchApp isEqual:[ai name]])
- matchIdx = [apps count];
- [apps addObject:ai];
- }
- }
- [resultTable reloadData];
-
- if ([resultTable numberOfRows] > 0) {
- [resultTable selectRow:matchIdx byExtendingSelection:NO];
- [resultTable scrollRowToVisible:matchIdx];
- }
- }
-
-
- -(void)awakeFromNib {
- NSRange r = [@@"testtest" rangeOfString:@@"st" options:0 range:NSMakeRange(4, 4)];
- [self setAllApps];
- apps = [[NSMutableArray alloc] init];
- appDS = [[AppTableDS alloc] init];
- [appDS setAppList:apps];
- NSTableColumn *ic = [resultTable tableColumnWithIdentifier:@@"i"];
- [ic setDataCell: [[NSImageCell alloc] init]];
- [resultTable setDataSource: appDS];
- //[[NSApplication sharedApplication] setDelegate:self];
- [self setApps];
- prefs = [SearchPrefs new];
- [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
- lt = [LaunchTextView new];
- [lt setFieldEditor:YES];
- [lt setTableView:resultTable];
- }
-
- - (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)anObject {
- if (anObject == searchField)
- return lt;
- return nil;
- }
-
- -(void)launch: (int)r {
- [[searchField window] makeFirstResponder:searchField];
- if (r < 0 || r >= [apps count])
- return;
- AppInfo *ai = [apps objectAtIndex:r];
- if ([ai launch] == NO)
- NSBeep();
- else {
- NSString *sv = [searchField stringValue];
- sv = [sv stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
- if ([sv length] > 0)
- [prefs setApp:[ai name] forString:sv];
- //[[NSApplication sharedApplication] hide:nil];
- }
- }
-
- - (void)tableViewSelectionDidChange:(NSNotification *)aNotification {
- if ([searchPanel firstResponder] == resultTable)
- [self launch: [resultTable selectedRow]];
- }
-
- - (void)windowDidBecomeKey:(NSNotification *)aNotification {
- [searchField setStringValue: @@""];
- [self setAllApps];
- [self setApps];
- }
-
- -(void)windowWillClose:(NSNotification *)aNotification {
- [[NSApplication sharedApplication] terminate:nil];
- }
-
- - (void)controlTextDidChange:(NSNotification *)aNotification {
- [self setApps];
- }
-
- -(IBAction)enterPressed: (id)sender {
- [self launch: [resultTable selectedRow]];
- }
- @@end
- @
-
-
- 1.2
- log
- @*** empty log message ***
- @
- text
- @d97 1
- a97 1
- [[NSApplication sharedApplication] hide:nil];
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d74 9
- @
-
-
- 1.1.1.1
- log
- @RocketLauncher
- @
- text
- @@
-